/*
||
|| @author Alexander Brevig
|| @version 1.3
||
*/

#include "TimedAction.h"

/*
|| <<constructor>>
*/
TimedAction::TimedAction(unsigned int intervl,void (*function)()){
    active = true;
	previous = 0;
	interval = intervl;
	execute = function;
}

/*
|| <<constructor>>
*/
TimedAction::TimedAction(unsigned long prev,unsigned int intervl,void (*function)()){
    active = true;
	previous = prev;
	interval = intervl;
	execute = function;
}

void TimedAction::disable(){
    active = false;
}

void TimedAction::enable(){
	active = true;
}

void TimedAction::check(){
  if ( active && (millis()-previous >= interval) ) {
    previous = millis();
    execute();
  }
}

/*
|| Changelog:
||
|| 2009-04-16 - Alexander Brevig : Coded disable() and enable()
|| 2009-04-16 - Alexander Brevig : Added a constructor
|| 2009-03-23 - Alexander Brevig : Initial Release
*/